package com.yidu.hbatsams.service.Impl;

import com.github.pagehelper.PageHelper;
import com.yidu.hbatsams.dao.AtsEmpAthleteResultsMapper;
import com.yidu.hbatsams.domain.AtsEmpAthleteResults;
import com.yidu.hbatsams.service.emp.AtsEmpAthleteResultsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.sql.Date;
import java.util.List;
@Service
public class AtsEmpAthleteResultsServiceImpl implements AtsEmpAthleteResultsService {
    @Resource
    AtsEmpAthleteResultsMapper atsEmpAthleteResultsMapper;
    /**
     * 查询所有+模糊查询
     * @param matchName
     * @return
     */
    @Override
    public List<AtsEmpAthleteResults> selectAll(Integer pageNum, Integer pageSize,String matchName, String startTime, String endTime) {
        PageHelper.startPage(pageNum,pageSize);;
        return atsEmpAthleteResultsMapper.selectAll(matchName,startTime,endTime);
    }

    /**
     * 查询行数
     * @return
     */
    @Override
    public Long count() {
        return atsEmpAthleteResultsMapper.count();
    }

    @Override
    public Long coutCoachResults(Integer coachId) {
        return atsEmpAthleteResultsMapper.coutCoachResults(coachId);
    }

    /**
     * 逻辑删除
     * @param resultId
     * @return
     */
    @Override
    public int deleteByPrimaryKey(Integer resultId) {
        return atsEmpAthleteResultsMapper.deleteByPrimaryKey(resultId);
    }

    /**
     * 新增
     * @param record
     * @return
     */
    @Override
    public int insert(AtsEmpAthleteResults record) {
        record.setIsva(1);
        record.setCreatTime(new Date(System.currentTimeMillis()));
        int ats = atsEmpAthleteResultsMapper.insert(record);
        return ats;
    }

    /**
     * 修改
     * @param record
     * @return
     */
    @Override
    public int updateByPrimaryKey(AtsEmpAthleteResults record) {
        record.setIsva(1);
        record.setCreatTime(new Date(System.currentTimeMillis()));
        int ats = atsEmpAthleteResultsMapper.updateByPrimaryKey(record);
        return ats;
    }

    /**
     * 根据ID查询
     * @param resultId
     * @return
     */
    @Override
    public AtsEmpAthleteResults selectByPrimaryKey(Integer resultId) {
        return atsEmpAthleteResultsMapper.selectByPrimaryKey(resultId);
    }

    /**
     * 根据教练查询比赛信息
     * @param matchName
     * @param coachId
     * @return
     */
    @Override
    public List<AtsEmpAthleteResults> selectAllCoach(Integer pageNum, Integer pageSize,String matchName,String startTime, String endTime, Integer coachId) {
        PageHelper.startPage(pageNum,pageSize);;
        return atsEmpAthleteResultsMapper.selectAllCoach(matchName,startTime,endTime,coachId);
    }
}
